package twoD.hofem.Q;

/**
 * A Constraint object imposes zero function values for one or 
 * more fields at a node or along an edge.
 * 
 * @author Team1
 *
 */
public class Constraint {
	
	private boolean[] free;
	
	/**
	 * Constructs an constraint object using the specified parameters. 
	 * A value of false at the i-th position of the input array indicates that 
	 * the i-th field must be zero along the corresponding node or edge.
	 * 
	 * @param free 
	 */
	public Constraint(boolean... free) {
		this.free = free; 
	}
	
	/**
	 * Tests if the field at the specified index can have non-zero values.
	 * DOFs that have index higher than the number of constrains in this Constraint
	 * are regarded as unconstrained.
	 * 
	 * @param idx
	 * @return True if it is free.
	 */
	public boolean isFree(int idx){
		if (idx > free.length-1)
			return true;
		else
			return free[idx];
	}

}
